<template>
	<view class="content">
		<view class="fixedtop">
			<view class="pageHeader">
				文件夹
				<a class="generalBack" @click="backpage()" hover-class="none">
				 <image src="/static/b-1.png" style="width: 18upx;height: 30upx;"></image>
				 </a>
			</view>
			<view style="padding: 0 30upx;margin-top: 30upx;">
				<view class="sdbox">
					<view class="filetitle">SDVS</view>
					<view class="flex aic jsb" style="padding-bottom: 30upx;border-bottom: 2upx solid #eee;">
						<view class="flex aic">
							<view class="filecode">{{myfilemsg.file_address?myfilemsg.file_address:'文件编号'}}</view>
							<image src="../../static/exchange/fcode.png" style="width: 60upx;height: 56upx;margin-left:16upx ;" @click="shouqu"></image>
						</view>
						<view class="xieyi" @click="xieyi">协议</view>
					</view>
					<view class="flex aic jsb" style="margin-top: 22upx;">
						<view class="flex aic">
							<image src="../../static/exchange/ex-3.png" style="width: 36upx;height: 28upx;margin-right:18upx ;"></image>
							<text class="fileleft">用户持有文件总量</text>
						</view>
						<text class="fileright">{{myfilemsg.total_file_num?myfilemsg.total_file_num:0}}份</text>
					</view>
					<view class="flex aic jsb" style="margin-top: 32upx;">
						<view class="flex aic">
							<image src="../../static/exchange/ex-4.png" style="width: 36upx;height:36upx;margin-right:18upx "></image>
							<text class="fileleft">账户所有文件总价值</text>
						</view>
						<text class="fileright">￥{{myfilemsg.account_total_file_value?myfilemsg.account_total_file_value:0}}</text>
					</view>
				</view>
				<view class="wenjian flex aic jsb">
					<text>文件</text>
					<image src="../../static/exchange/ex-5.png" style="width: 36upx;height: 36upx;"></image>
				</view>
			</view>
		</view>
		<view class="regoodbox">
			<view v-if="fileList.length<=0" class="empty">
				<image src="/static/empty.png" mode="widthFix"></image>
				<view class="empty-tips">
					暂无文件~
				</view>
			</view>
			<view class="myfiles" v-if="fileList.length>0">
				<view>
					<view v-for="(fitem,findex) in myfilelist" :key = "findex" @click="godetail(fitem)" class="flex aic jsb fileitem">
						<view class="flex aic">
							<view class="grey"></view>
							<text>{{fitem.code}}({{fitem.file_num}}份)</text>
						</view>
						<text class="itemnum">￥{{fitem.total_valuepershare}}</text>
					</view>
				</view>
			</view>
		</view>
		<!-- <view class="customer" >
			<view class="customerbox flex aic">
				<image src="../../static/c-11.jpg" class="customerimg"></image>
				<view class="middlein">
					<view class="middleitem">联盟商名称</view>
					<view class="middleitem btmadv">广告词</view>
				</view>
				<view class="btmxieyi" @click="xieyi">协议</view>
			</view>
		</view> -->
	</view>
	</template>
	<script>
	import postAjax from '../../API/postAjax.js'
	export default {
		data() {
			return {
				userToken:'',// token
				fileList:[1],
				page :0,
				loadingText: '加载中...',
				// 请求的对象
				myfilemsg:{},
				myfilelist:[]
			}
		},
		onLoad(options) {
			let that = this
			that.userToken = uni.getStorageSync('token')
			that.getFileList()

		},
		methods: {
			// 返回上一页
			backpage(){
				uni.navigateBack({
					delta:1
				})
			},
			godetail(item){
				let ointro = item.file_introduce
				delete item.file_introduce
				uni.navigateTo({
					url:'filedetail?item='+JSON.stringify(item),
					animationDuration:300
				})
			},
			// 协议
			xieyi(){
				let that = this
				let ofile = that.myfilemsg.data
				let sdvsfile = ofile.filter(i=>i.code=='SDVS')
				console.log(sdvsfile)
				uni.navigateTo({
					url:"agreement?id="+sdvsfile[0].id
				})
			},
			shouqu(){
				uni.navigateTo({
					url:"filecode"
				})
			},
			// 转让页面
			gotrans(i){
				uni.navigateTo({
					url:'transout'
				})
			},
			//滚动到底部
			
			onReachBottom:function(){
				this.getFileList();
			},
			//获取订单列表
			getFileList() {
				let that = this;
				uni.showNavigationBarLoading();
				let postdata = {
					token: that.userToken,
					m: that.page,
					n: 6
				};
				// 我的订单列表
				let fileLog = [];
				postAjax('File/fileList', postdata, function(data) {
					console.log(data)
					if (data.code == 0) {
						that.myfilemsg = data.data
						fileLog = data.data.data
						if (fileLog.length > 0) {
							that.myfilelist = that.myfilelist.concat(fileLog);
							that.page++; //每触底一次 page +1
						} else {					
							that.loadingText = '已加载全部';				
						}
						
						if(that.myfilelist.length<10){
							that.loadingText = '';
						}
						uni.hideNavigationBarLoading();
					}else{
						fileLog = []
						uni.hideNavigationBarLoading();
					}
				});
			}
		}
	}
	
</script>

<style>
	.content{min-height: 100vh;background-color: #fff;}
	.fixedtop{position: fixed;top:0;left:0;z-index:999;width: 100%;background-color: #fff;}
	.pageHeader{height: 128upx;background-color: #1D84E8;line-height: 128upx;text-align: center;font-size: 36upx;color: #fff;padding-top: 40upx;}
	.generalBack{position: absolute;top:40upx;left:30upx;display: block;}
	.regoodbox{padding: 580upx 30upx 0upx;}
	.eliplis{overflow: hidden;white-space: nowrap;text-overflow: ellipsis}
	.sdbox{border:2upx solid #9DCCFB;border-radius: 20upx;padding: 20upx 24upx;}
	.filetitle{font-size: 30upx;color: #333;margin-bottom: 16upx;}
	.filecode{width: 346upx;padding:16upx 0;background-color: #CBE5FF;border-radius: 10upx;text-align: center;color: #333;font-size: 28upx;}
	.xieyi{padding: 16upx 40upx;background-color: #1D84E8;border-radius: 10upx;color: #fff;font-size: 28upx}
	.btmxieyi{padding: 16upx 20upx;background-color: #EC6104;border-radius: 10upx;color: #fff;font-size: 28upx}
	.fileleft{font-size: 28upx;color: #333;}
	.fileright{font-size: 28upx;color: #666;}
	.myfiles{margin-top: 50upx;}
	.wenjian{padding: 0 24upx 30upx;font-size: 30upx;color: #333;margin-top: 40upx;}
	.fileitem{padding: 28upx 24upx; font-size: 28upx;color: #333;border-top:2upx solid #eee}
	.grey{width: 30upx;height: 30upx;background-color: #DDDDDD;margin-right: 18upx;}
	.itemnum{color: #666;}
	.customer{position: fixed;width: 100%;left: 0;bottom: 0;z-index:999;height: 150upx;padding-bottom:30upx;}
	.customerbox{margin: 0 30upx;background-color: #F9F9F9;border-radius: 10upx;}
	.customerimg{width: 148upx;height: 152upx;background-color: #999;border-radius: 10upx 0 0 10upx;}
	.middlein{flex:1;font-size: 28upx;color: #333;text-align: center;padding: 0 22upx;}
	.middleitem{padding:28upx 0 16upx;}
	.btmadv{color: #666;border-top:2upx solid #ddd}
	.empty {
		position: fixed;
		left: 0;
		top: 0;
		width: 100%;
		height: 100vh;
		padding-bottom: 100upx;
		display: flex;
		justify-content: center;
		flex-direction: column;
		align-items: center;
		background: #fff;
	
	}
	
	.empty image {
		width:240upx;
		margin-bottom: 30upx;
	}
	.empty-tips {
		display: flex;
		font-size: 30upx;
		color: #666;
	
	}
</style>
